// 存储 Vanta 效果实例
let vantaEffect = null;

// 初始化 Vanta 背景的函数
function initVantaBackground(containerId = 'vantaRef', config = {}) {
    const defaultConfig = {
        mouseControls: true,
        touchControls: true,
        gyroControls: false,
        minHeight: 200.00,
        minWidth: 200.00,
        scale: 1.00,
        scaleMobile: 1.00,
        color: 0x245282,
        shininess: 36.00,
        waveHeight: 23.50,
        waveSpeed: 0.50,
        zoom: 0.78
    };

    const finalConfig = {
        ...defaultConfig,
        ...config,
        el: document.getElementById(containerId)
    };

    if (finalConfig.el) {
        vantaEffect = VANTA.WAVES(finalConfig);
    }

    return vantaEffect;
}

// 销毁 Vanta 背景的函数
function destroyVantaBackground() {
    if (vantaEffect) {
        vantaEffect.destroy();
        vantaEffect = null;
    }
}

// 导出初始化和销毁函数
export { initVantaBackground, destroyVantaBackground };
